package com.dmitriyp.movie.console.actions;

import static java.lang.System.out;

import java.util.List;

import com.dmitriyp.movie.console.IUserAction;
import com.dmitriyp.movie.console.UserInputUtil;
import com.dmitriyp.movie.dao.IMovieManager;
import com.dmitriyp.movie.dao.Order;
import com.dmitriyp.movie.mapping.Movie;

public class UserListAction implements IUserAction {

    private final IMovieManager manager;
    private final Order order;

    public UserListAction(IMovieManager manager, Order order) {
        this.manager = manager;
        this.order = order;
    }

    public void doAction() {
        List<Movie> movies = manager.listAll(order);
        for (Movie movie : movies) {
            printMovie(movie);
        }
        out.println();
        UserInputUtil.pressAnyKey();
    }

    protected void printMovie(Movie movie) {
        out.println(movie.getId() + " - " + movie.getTitle());
    }

}
